package com.reflectapply2.apply2;

import com.reflectapply2.data.Person;
import org.junit.Test;

import java.lang.reflect.Field;

public class FieldsTest {
    @Test
    public void test1(){
        Class<Person> clazz = Person.class;
//        getDeclaredFields();获取当前运行时类中声明的所有属性
        Field[] declaredFields = clazz.getDeclaredFields();
        for (Field f : declaredFields) {
            System.out.println(f);
        }
//        getFields():获取到运行时类本身及所有父类中声名的public权限属性
        Field[] fields = clazz.getFields();
        for (int i = 0; i < fields.length; i++) {
            System.out.println(fields[i]);

        }



    }
}
